package com.wenhao.ctrip;

import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author Wenhao Tong
 * @create 2021-09-09 19:16
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        LinkedList<String> folders = new LinkedList<>();
        for (int i = 0;i < n;i++) {
            String next = scanner.next();
            if (next.equals("cd")) {
                String folder = scanner.next();
                if (folder.equals("..")) {
                    folders.pollLast();
                } else {
                    folders.offerLast("\\" + folder);
                }
            } else if (next.equals("pwd")) {
                if (folders.size() == 0) {
                    System.out.println("\\");
                } else {
                    for (String s : folders) {
                        System.out.print(s);
                    }
                    System.out.println();
                }
            }
        }
    }
}
